package mm1.GUI;

import javafx.scene.CustomNode;
import javafx.scene.Node;
import javafx.scene.control.TextBox;
import javafx.scene.layout.HBox;
import javafx.scene.Group;
import javafx.scene.text.Text;
import javafx.scene.control.Label;
import javafx.ext.swing.SwingButton;
import java.lang.System;
import javax.swing.JFileChooser;

/**
 * Layout for GUI elemnts for file manipulation controls
 *
 * @author Ralph Hoch, Matthias Heisler
 */

public class OpenControlsScreen extends CustomNode {
    
	var fileBox:TextBox = TextBox{}
	public var vds:VideoScreen;
	
    public var isVisible:Boolean = false;
    
    
	/**
	 * Create the open File controls
	 */
	public override function create():Node {
		return  Group {
	        content: [
	    		HBox {
	      			height: bind scene.width * 0.1
	       			visible: bind isVisible
					spacing: 3
	       			content: [
	       				Label { text: "URL/FILE: "},
	       				fileBox,
	       				SwingButton {
	       					text: "searchFile"
	       				   	action: function() {
	       				  		println("Search File");
	       				     	var chooser = new JFileChooser();
	       				       	if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
	       				         	fileBox.text = chooser.getSelectedFile().toURI().toString();
	       				       	}
	       				 	}
	       				}
		       			SwingButton {
		       				text: "Load"
		       				action: function() {
		       				   	println("Load");
		       				  	vds.setVideo(fileBox.text);
		       				}
	       				}
						SwingButton {
		       				text: "Export"
		       				action: function() {
		       				   	println("EXPORT VIDEO");
		       				}
	       				}
	       			]
	    		} 
        	]
		}
    }
 
}